
const numMap = {
    0: '+[]',
    1: '+!![]',
    2: '!+[]+!![]',
};
for (let i = 3; i <= 9; i++)numMap[i] = numMap[i - 1] + '+!![]';

/**
 * 
 * @desc 生成一位数字对应运算符
 * @param  {Number} min 
 * @param  {Number} n 
 * @param  {Boolean} s 
 * @return {String} 
 */
const num = function (n, s) {
    let num = numMap[n];
    return s == true ? num + '+[]' : num;
};

/**
 * 
 * @desc 生成多位数字对应运算符
 * @param  {Number} n  
 * @return {String} 
 */
const nums = function (n) {
    let chars = n.toString().split("");
    return "+(" + chars.map((v, i) => {
        let c = num(v);
        return `(${i == 0 ? c + num(0) : c})`;
    }).join("+") + ")";
};


module.exports = {
    num, nums
};